﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ScenarioFramework.WorkflowEngine.Database.WorkflowProcesses;
using ScenarioFramework.WorkflowEngine.DataModel.WorkflowProcesses;
using ScenarioFramework.WorkflowEngine.DataBase;

namespace ScenarioFramework.Portal.SF.Reports.UserControls
{
    public partial class BAMActivity : System.Web.UI.UserControl
    {
        Activity activity = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            activity = ViewState["Activity"] == null ? new Activity() : (Activity)ViewState["Activity"];

            activity.ProcessId = Request.QueryString["ProcessId"] == null ? 0 : long.Parse(Request.QueryString["ProcessId"]);
            activity.ActivityId = Request.QueryString["ActivityId"];

            IList activityList = Helpers.ActivityHelper().DynamicGetActivityList(activity);

            this.GridView1.DataSource = activityList;
            this.GridView1.DataBind();

            if (activityList.Count > 0)
            {
                Activity activity2Show = (Activity)activityList[0];
                XMLLog log = new XMLLog();
                XMLLogs logs = new XMLLogs();

                log.Parse(activity2Show.Log);
                logs.Parse(activity2Show.Logs);

                this.PlaceHolder1.Controls.Add(new LiteralControl(log.GetXML(true, 0)));
                this.PlaceHolder1.Controls.Add(new LiteralControl("<hr>"));
                this.PlaceHolder1.Controls.Add(new LiteralControl(logs.GetXML(true, 0)));
            }
        }
    }
}